| Path: | merb-slices/lib/generators/templates/thin/lib/%base_name%.rb |
| Last Update: | Tue Jul 28 08:32:52 +0200 2009 |
Activation hook - runs after AfterAppLoads BootLoader
# File merb-slices/lib/generators/templates/thin/lib/%base_name%.rb, line 33
33: def self.activate
34: end
Deactivation hook - triggered by Merb::Slices.deactivate(<%= module_name %>)
# File merb-slices/lib/generators/templates/thin/lib/%base_name%.rb, line 37
37: def self.deactivate
38: end
Initialization hook - runs before AfterAppLoads BootLoader
# File merb-slices/lib/generators/templates/thin/lib/%base_name%.rb, line 29
29: def self.init
30: end
This sets up a thin slice‘s structure.
# File merb-slices/lib/generators/templates/thin/lib/%base_name%.rb, line 55
55: def self.setup_default_structure!
56: self.push_app_path(:root, Merb.root / 'slices' / self.identifier, nil)
57:
58: self.push_path(:stub, root_path('stubs'), nil)
59: self.push_app_path(:stub, app_dir_for(:root), nil)
60:
61: self.push_path(:application, root, 'application.rb')
62: self.push_app_path(:application, app_dir_for(:root), 'application.rb')
63:
64: self.push_path(:view, dir_for(:application) / "views")
65: self.push_app_path(:view, app_dir_for(:application) / "views")
66:
67: self.push_path(:public, root_path('public'), nil)
68: self.push_app_path(:public, Merb.root / 'public' / 'slices' / self.identifier, nil)
69:
70: public_components.each do |component|
71: self.push_path(component, dir_for(:public) / "#{component}s", nil)
72: self.push_app_path(component, app_dir_for(:public) / "#{component}s", nil)
73: end
74: end
Setup routes inside the host application
@param scope<Merb::Router::Behaviour>
Routes will be added within this scope (namespace). In fact, any router behaviour is a valid namespace, so you can attach routes at any level of your router setup.
@note prefix your named routes with :<%= symbol_name %>_
to avoid potential conflicts with global named routes.
# File merb-slices/lib/generators/templates/thin/lib/%base_name%.rb, line 49
49: def self.setup_router(scope)
50: # enable slice-level default routes by default
51: scope.default_routes
52: end